package com.cnswhy.cloud.server.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnswhy.cloud.common.core.base.entity.Entity;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.cnswhy.cloud.common.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.cnswhy.cloud.server.common.entity.enumeration.ConfigKey;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 系统配置表
 * </p>
 *
 * @author cnswhy
 * @since 2020-10-16
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_sys_config")
@ApiModel(value = "SysConfig", description = "系统配置表")
@AllArgsConstructor
public class SysConfig extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 配置类型 #ConfigKey{file_ftp_ip:fTP文件IP;}
     */
    @ApiModelProperty(value = "配置类型 #ConfigKey{file_ftp_ip:fTP文件IP;}")
    @TableField("config_key")
    @Excel(name = "配置类型 #ConfigKey{file_ftp_ip:fTP文件IP;}", replace = {"fTP文件IP_FILE_FTP_IP",  "_null"})
    private String configKey;

    /**
     * 配置名称
     */
    @ApiModelProperty(value = "配置名称")
    @Length(max = 200, message = "配置名称长度不能超过200")
    @TableField(value = "config_name", condition = LIKE)
    @Excel(name = "配置名称")
    private String configName;

    /**
     * 配置VALUE
     */
    @ApiModelProperty(value = "配置VALUE")
    @Length(max = 2000, message = "配置VALUE长度不能超过2000")
    @TableField(value = "config_value", condition = LIKE)
    @Excel(name = "配置VALUE")
    private String configValue;

    /**
     * 类型（1：系统参数配置，2：业务URL配置，3：接口路径配置）
     */
    @ApiModelProperty(value = "类型（1：系统参数配置，2：业务URL配置，3：接口路径配置）")
    @Length(max = 1, message = "类型（1：系统参数配置，2：业务URL配置，3：接口路径配置）长度不能超过1")
    @TableField(value = "type", condition = LIKE)
    @Excel(name = "类型（1：系统参数配置，2：业务URL配置，3：接口路径配置）")
    private String type;

    /**
     * 校验规则，正则表达式
     */
    @ApiModelProperty(value = "校验规则，正则表达式")
    @Length(max = 2000, message = "校验规则，正则表达式长度不能超过2000")
    @TableField(value = "validate_rules", condition = LIKE)
    @Excel(name = "校验规则，正则表达式")
    private String validateRules;

    /**
     * 配置规则描述
     */
    @ApiModelProperty(value = "配置规则描述")
    @Length(max = 2000, message = "配置规则描述长度不能超过2000")
    @TableField(value = "config_rules", condition = LIKE)
    @Excel(name = "配置规则描述")
    private String configRules;

    /**
     * 配置分组
     */
    @ApiModelProperty(value = "配置分组")
    @Length(max = 200, message = "配置分组长度不能超过200")
    @TableField(value = "config_group", condition = LIKE)
    @Excel(name = "配置分组")
    private String configGroup;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @TableField("create_date")
    @Excel(name = "创建时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime createDate;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @TableField("update_date")
    @Excel(name = "更新时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime updateDate;

    /**
     * 是否显示 0-隐藏 1-显示
     */
    @ApiModelProperty(value = "是否显示 0-隐藏 1-显示")
    @Length(max = 1, message = "是否显示 0-隐藏 1-显示长度不能超过1")
    @TableField(value = "display_status", condition = LIKE)
    @Excel(name = "是否显示 0-隐藏 1-显示")
    private String displayStatus;


    @Builder
    public SysConfig(Long id, LocalDateTime createTime, LocalDateTime updateTime, Long createUser, Long updateUser,
                     String configKey, String configName, String configValue, String type, String validateRules,
                    String configRules, String configGroup, LocalDateTime createDate, LocalDateTime updateDate, String displayStatus) {
        this.id = id;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.createUser = createUser;
        this.updateUser = updateUser;
        this.configKey = configKey;
        this.configName = configName;
        this.configValue = configValue;
        this.type = type;
        this.validateRules = validateRules;
        this.configRules = configRules;
        this.configGroup = configGroup;
        this.createDate = createDate;
        this.updateDate = updateDate;
        this.displayStatus = displayStatus;
    }

}
